package cn.changeforyou.web;

import cn.changeforyou.web.blog.luceneAop.LuceneStarter;
import cn.changeforyou.web.nutz.common.MyActionChainMaker;
import cn.changeforyou.web.nutz.common.security.JwtFilter;
import cn.changeforyou.web.nutz.common.security.MyCorsFilter;
import org.nutz.boot.NbApp;
import org.nutz.dao.Dao;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.ChainBy;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.IocBy;


/**
 * @author zhyu
 */
@IocBean(create="init", depose="depose")
//@SetupBy(value = LuceneStarter.class)
@ChainBy(type = MyActionChainMaker.class, args = {})
@Filters({@By(type = MyCorsFilter.class, args = {"https://www.changeforyou.cn", "GET, POST, PUT, DELETE, OPTIONS, PATCH", "Origin, Content-Type, Accept, X-Requested-With, authorization", "true"}), @By(type = JwtFilter.class)})
@IocBy(args={
    "*js", "ioc/", // 读取ioc/下的js/json配置文件
    "*anno", "cn.changeforyou.web", // 扫描package下的ioc注解
    "*tx", // 启用内置的事务拦截器 例如: @Aop(TransAop.txREAD_COMMITTED)
    "*async", "48", // 启用异步执行注解拦截器, 后面的48是线程池大小. 即注解@Async
    "*cn.changeforyou.web.blog.luceneAop.LuceneAopLoader" // 自定义aop注解加载器
})
public class MainLauncher {

    @Inject
    protected PropertiesProxy conf;
    @Inject
    protected Dao dao;

    public void init() {
//        dao.create(Order.class, false);
    }

    public void depose() {}

    public static void main(String[] args) throws Exception {
        new NbApp().setArgs(args).setPrintProcDoc(false).run();
    }

}
